<?php
require ('./util/request.php');
require ('./util/DB.php');
//require ('./controller/User.php');
//require ('./controller/Type.php');
//require ('./controller/Article.php');
//require ('./controller/Banner.php');
//require ('./controller/Life.php');
spl_autoload_register(function ($name) {
    require ("./controller/{$name}.php");
});

header("Access-Control-Allow-Origin: *");
header("Access-Control-Allow-Methods: POST, GET, OPTIONS, PUT, DELETE");
header('Access-Control-Allow-Headers:x-requested-with,content-type');
header("Content-Type: text/html;charset=utf-8");
$db = new DB('localhost:3306','myboke','myboke','123456');
get('/boke/index.php/login',function ($req){
    global $db;
   $user = new User( $db,$req);
   $user->login();
});
get('/boke/index.php/findInfo',function ($req){
    global $db;
    $user = new User( $db,$req);
    $user->findInfo();
});
get('/boke/index.php/addAsk',function ($req){
    global $db;
    $user = new User( $db,$req);
    $user->addAsk();
});

////////////类型
post('/boke/index.php/addType',function ($req){
    global $db;
    $t = new Type( $db,$req);
    $t->add();
});
post('/boke/index.php/editType',function ($req){
    global $db;
    $t = new Type( $db,$req);
    $t->edit();
});
get('/boke/index.php/findType',function ($req){
    global $db;
    $t = new Type( $db,$req);
    $t->find();
});
get('/boke/index.php/delType',function ($req){
    global $db;
    $t = new Type( $db,$req);
    $t->del();
});

///////////////文章
post('/boke/index.php/addArticle',function ($req){
    global $db;
    $t = new Article( $db,$req);
    $t->add();
});

post('/boke/index.php/editArticle',function ($req){
    global $db;
    $t = new Article( $db,$req);
    $t->edit();
});
get('/boke/index.php/findArticle',function ($req){
    global $db;
    $t = new Article( $db,$req);
    $t->find();
});
get('/boke/index.php/findPageTArticle',function ($req){
    global $db;
    $t = new Article( $db,$req);
    $t->findT();
});
get('/boke/index.php/findArticleDes',function ($req){
    global $db;
    $t = new Article( $db,$req);
    $t->des();
});
get('/boke/index.php/delArticle',function ($req){
    global $db;
    $t = new Article( $db,$req);
    $t->del();
});

//////////////banner
get('/boke/index.php/findBanner',function ($req){
    global $db;
    $t = new Banner( $db,$req);
    $t->find();
});
get('/boke/index.php/showBanner',function ($req){
    global $db;
    $t = new Banner( $db,$req);
    $t->showBanner();
});
get('/boke/index.php/findBannerDes',function ($req){
    global $db;
    $t = new Banner( $db,$req);
    $t->des();
});
post('/boke/index.php/addBanner',function ($req){
    global $db;
    $t = new Banner( $db,$req);
    $t->add();
});
post('/boke/index.php/editBanner',function ($req){
    global $db;
    $t = new Banner( $db,$req);
    $t->edit();
});
get('/boke/index.php/delBanner',function ($req){
    global $db;
    $t = new Banner( $db,$req);
    $t->del();
});
get('/boke/index.php/effectBanner',function ($req){
    global $db;
    $t = new Banner( $db,$req);
    $t->effect();
});
//////////////life
 get('/boke/index.php/findLife',function ($req){
    global $db;
    $t = new Life( $db,$req);
    $t->find();
});
get('/boke/index.php/findLifeDes',function ($req){
    global $db;
    $t = new Life( $db,$req);
    $t->des();
});
post('/boke/index.php/addLife',function ($req){
    global $db;
    $t = new Life( $db,$req);
    $t->add();
});
post('/boke/index.php/editLife',function ($req){
    global $db;
    $t = new Life( $db,$req);
    $t->edit();
});
get('/boke/index.php/delLife',function ($req){
    global $db;
    $t = new Life( $db,$req);
    $t->del();
});

//////codelife
///
get('/boke/index.php/findCodeLife',function ($req){
    global $db;
    $t = new CodeLife( $db,$req);
    $t->find();
});
get('/boke/index.php/findCodeDes',function ($req){
    global $db;
    $t = new CodeLife( $db,$req);
    $t->des();
});
post('/boke/index.php/addCodeLife',function ($req){
    global $db;
    $t = new CodeLife( $db,$req);
    $t->add();
});
post('/boke/index.php/editCodeLife',function ($req){
    global $db;
    $t = new CodeLife( $db,$req);
    $t->edit();
});
get('/boke/index.php/delCodeLife',function ($req){
    global $db;
    $t = new CodeLife( $db,$req);
    $t->del();
});

//////manger
///
get('/boke/index.php/findManger',function ($req){
    global $db;
    $t = new Manger( $db,$req);
    $t->find();
});
get('/boke/index.php/findGjDes',function ($req){
    global $db;
    $t = new Manger( $db,$req);
    $t->des();
});
post('/boke/index.php/addManger',function ($req){
    global $db;
    $t = new Manger( $db,$req);
    $t->add();
});
post('/boke/index.php/editManger',function ($req){
    global $db;
    $t = new Manger( $db,$req);
    $t->edit();
});
get('/boke/index.php/delManger',function ($req){
    global $db;
    $t = new Manger( $db,$req);
    $t->del();
});

//////share
///
get('/boke/index.php/findShare',function ($req){
    global $db;
    $t = new Share( $db,$req);
    $t->find();
});
get('/boke/index.php/findShareDes',function ($req){
    global $db;
    $t = new Share( $db,$req);
    $t->des();
});
post('/boke/index.php/addShare',function ($req){
    global $db;
    $t = new Share( $db,$req);
    $t->add();
});
post('/boke/index.php/editShare',function ($req){
    global $db;
    $t = new Share( $db,$req);
    $t->edit();
});
get('/boke/index.php/delShare',function ($req){
    global $db;
    $t = new Share( $db,$req);
    $t->del();
});

//////link
///
get('/boke/index.php/findLink',function ($req){
    global $db;
    $t = new Link( $db,$req);
    $t->find();
});
post('/boke/index.php/addLink',function ($req){
    global $db;
    $t = new Link( $db,$req);
    $t->add();
});
post('/boke/index.php/editLink',function ($req){
    global $db;
    $t = new Link( $db,$req);
    $t->edit();
});
get('/boke/index.php/delLink',function ($req){
    global $db;
    $t = new Link( $db,$req);
    $t->del();
});